﻿#ifndef WQSCENE_H
#define WQSCENE_H


#include <QGraphicsSceneMouseEvent>
#include <QGraphicsItem>
#include <QGraphicsScene>

class wqLinkItem;
class wqBtnItem;

class wqScene : public QGraphicsScene
{
    Q_OBJECT

public:
    wqScene(int idx, QObject* parent = NULL);

signals:
	void sig_changeScene(int idx);

protected:
    virtual void mousePressEvent ( QGraphicsSceneMouseEvent * ev );                          		// 鼠标按下事件
    virtual void mouseMoveEvent( QGraphicsSceneMouseEvent * ev );                            		// 鼠标移动事件
    virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * ev );                        		// 鼠标释放事件

    virtual void drawForeground(QPainter *painter, const QRectF &rect);
    virtual void drawBackground(QPainter *painter, const QRectF &rect);

private:
    void CreateItems();
    QTransform GetViewTransform();
    QGraphicsItem* GetCurrentItem(const QString& name);

private slots:
    void slot_posChanged();

private:
    QPointF mLastPoint;
    QPointF mNowPoint;
	QPointF mItemPos;

    QLineF mLine;

    bool mbLinking;
	int mIndex;

    QGraphicsItem* mLastItem;
	wqBtnItem* mLastBtnItem;

    QMultiMap<QString, wqLinkItem*> mMapItems;
};

#endif // WQSCENE_H
